#include<iostream>  
#include<Windows.h>
using namespace std;  
class CUser  
{  
public:  
    CUser();  
    virtual ~CUser();  
    char* WcharToChar(wchar_t* wc);//宽字节转单字节   
    wchar_t* CharToWchar(char* c); //单字节转宽字节   
    void Release();//释放资源   
private:  
    char* m_char;  
    wchar_t* m_wchar;  
};  
/////////////////////////////////////////////////////////////////////////////////////   
/*字符类型        wchar_t     char 
获取字符长度    wcslen()    strlen() 
连接两个字符串  wcscat()    strcpy() 
复制字符串      wcscpy()    strcpy() 
比较两个字符串  wcscmp()    strcmp()*/
////////////////////////////////////////////////////////////////////////////////////   
CUser::CUser():m_char(NULL),m_wchar(NULL)  
{  
}  
CUser::~CUser()  
{  
    Release();  
}  

//宽字节转单字节   
char* CUser::WcharToChar(wchar_t* wc)  
{  
    Release();  
    int len= WideCharToMultiByte(CP_ACP,0,wc,wcslen(wc),NULL,0,NULL,NULL);  
    m_char=new char[len+1];  
    WideCharToMultiByte(CP_ACP,0,wc,wcslen(wc),m_char,len,NULL,NULL);  
    m_char[len]='\0';  
    return m_char;  
}  

//单字节转宽字节   
wchar_t* CUser::CharToWchar(char* c)  
{  
    Release();  
    int len = MultiByteToWideChar(CP_ACP,0,c,strlen(c),NULL,0);  
    m_wchar=new wchar_t[len+1];  
    MultiByteToWideChar(CP_ACP,0,c,strlen(c),m_wchar,len);  
    m_wchar[len]='\0';  
    return m_wchar;  
}  

//释放资源   
void CUser::Release()  
{  
    if(m_char)  
    {  
        delete m_char;  
        m_char=NULL;  
    }  
    if(m_wchar)  
    {  
        delete m_wchar;  
        m_wchar=NULL;  
    }  
}